import request from '@/utils/request.js'



/**
 * 删除仓库
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function delWarehouse(id) {
  return request.delete('/admin/warehouse/', {
    params: {
      id: id
      // deptName: params?.deptName
    }
  })
}

/**
 * 添加仓库
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addWarehouse(data) {
  return request.post('/admin/warehouse/', data)
}

/**
 * 编辑仓库
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function editWarehouse(data) {
  return request.put('/admin/warehouse/', data)
}

/* ------------------物资管理---------------- */


/**
 * 删除物资
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function delMaterial(id) {
  return request.delete('/admin/material/', {
    params: {
      id: id
    }
  })
}

/**
 * 添加仓库
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addMaterial(data) {
  return request.post('/admin/material/', data)
}

/**
 * 编辑仓库
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function editMaterial(data) {
  // return request.put('/admin/material/', data)
  return request({
    url: '/admin/material/',
    method: 'put',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 导出仓库图片
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function export_materials(params) {
  return request.get('/admin/material/export_materials/', {
    params: {
      warehouse_id: params?.warehouse_id
    }
  })
}


/**
 * 导出仓库盘点结果表
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function export_excel(data) {
  // return request.post('/admin/excel/', {...data,responseType: 'blob'})
  return request({
    url: 'admin/excel/',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

/**
 * 导出仓库盘点结果表
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function export_excelModel(data) {
  // return request.post('/admin/excel/', {...data,responseType: 'blob'})
  return request({
    url: 'admin/excel/model',
    method: 'get',
    data,
    responseType: 'blob'
  })
}
